<me:UIAM x:Class="WPFExcelReport.TAMZLAN"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL"   
                    xmlns:LS="clr-namespace:WPFExcelReport;assembly=TLIEFDAT"   
                    xmlns:DR="clr-namespace:WPFExcelReport;assembly=TDRAUFTR"   
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                    xmlns:WH="clr-namespace:WPFExcelReport;assembly=TLAGPL"  
                    xmlns:KS="clr-namespace:WPFExcelReport;assembly=TKSTSTELL"  
                    xmlns:AMD="clr-namespace:WPFExcelReport;assembly=TAMMODUL"           
                    xmlns:AME="clr-namespace:WPFExcelReport;assembly=TAMEINST" 
                    xmlns:AE="clr-namespace:WPFExcelReport;assembly=TMEKOPF" 
                    xmlns:ZL="clr-namespace:WPFExcelReport;assembly=TICC_ZLAN" 
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIAM.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:Divideby10  x:Key="d10"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTBoolToVisibilityConverter  x:Key="nbv"/>
        <ucd:NOTConverter x:Key="not"/>
        <ucd:Divideby100  x:Key="d100"/>
        <ucd:Divideby1000  x:Key="d1000"/>
        <ucd:SDKEYCONV x:Key="sd"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:UIAM.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"  >
            <WrapPanel Visibility="Collapsed">
                <Button Click="ResetSeq" Content="{Binding Source={Localization:Translate Word=重置序列号}}"
                    Visibility="{Binding IsITX,Converter={StaticResource bv}}"/>
                <Grid Margin="10,0,0,0" VerticalAlignment="Top"  Visibility="Collapsed"
                      >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <DR:TDRAUFTR  Grid.Column="0" Name="cDR" DocType="{Binding PRTYPE,ElementName=TV}" PrintType="OpenExcel" />
                    <Button  Grid.Column="1"   Click="btnPrint_Click" Height="20" Margin="5,0,0,0" Width="Auto" 
                             Content="{Binding Source={Localization:Translate Word=打印确认函}}" />
                </Grid>
            </WrapPanel>
            <WrapPanel   >

                <Grid Margin="10,0,0,0" VerticalAlignment="Top" IsEnabled="{Binding IsCanChg,ElementName=TV}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button  Click="EditCommand" Width="24" Height="20">
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" VerticalAlignment="Top" 
                      IsEnabled="{Binding IsCanDelete,ElementName=TV}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                        </Button.Background>
                    </Button>
                </Grid>

                <Grid Margin="10,0,0,0" VerticalAlignment="Top"  
                      Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                        </Button.Background>
                    </Button>
                </Grid>

                <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=设备}}"/>
                <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2"   
                              CharacterCasing="Upper" Text="{Binding KRS,ElementName=TV}" Width="30" />
                <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  
                              Text="{Binding LFD,ElementName=TV}" KeyUp="Query_KeyUp" Width="60" />
                <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  
                              Text="{Binding POS,ElementName=TV}" KeyUp="Query_KeyUp" Width="40" />

                <Button Grid.Column="0"  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                    </Button.Background>
                </Button>

            </WrapPanel>
            <StackPanel>
                <WrapPanel>
                <Grid Margin="10,0,0,0"  VerticalAlignment="Top" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24"
                            IsEnabled="{Binding IsCanNew,ElementName=TV}"
                            >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                    <WrapPanel Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}">
                        <SD:K0224 KEY="{Binding AMART,ElementName=TV}"
                          IsEdit="True" 
                          />
                        <SD:K0228 KEY="{Binding AMTYP,ElementName=TV}"
                          IsEdit="True"
                          
                          />
                        <KS:TSKS03 Grid.Column="1"  
                                  IsEdit="True"
                                   KEY="{Binding Path=AMKST,ElementName=TV}"
                                    /> 
                    </WrapPanel>
                </WrapPanel>                
                    <WrapPanel Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}" >
                    <TextBlock Text="{Binding Source={Localization:Translate Word=设备编号}}"/>
                    <ex:TXT72 Text="{Binding KRS,ElementName=TV}" CharacterCasing="Upper" MaxLength="2" PRE="  " Width="30" />
                    <ex:TXT72 Text="{Binding LFD,ElementName=TV}" MaxLength="4" PRE="0000" Width="40"/>
                    <ex:TXT72 Text="{Binding POS,ElementName=TV}" MaxLength="2" PRE="00" Width="30"/>
                    <CheckBox Content="{Binding Source={Localization:Translate Word=多中位}}" Name="IsMM"/>
                    <ex:NumericBox Text="{Binding LFD,ElementName=TV}" DecimalPlaces="0"
                                   IsEnabled="{Binding IsChecked,ElementName=IsMM}" />
                    <CheckBox Content="{Binding Source={Localization:Translate Word=多末位}}" Name="IsMP" IsChecked="{Binding IsChecked,ElementName=IsMM,Converter={StaticResource not}}"/>
                    <ex:NumericBox Text="{Binding LFD,ElementName=TV}" DecimalPlaces="0" 
                                   IsEnabled="{Binding IsChecked,ElementName=IsMP}" />
                  
                    <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/button_ok.png" />
                        </Button.Background>
                    </Button>
                </WrapPanel> 
            </StackPanel>
            <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"  >
                <WrapPanel  >
                    <TextBlock Text="{Binding Source={Localization:Translate Word=设备编号:}}"/>
                    <TextBlock Text="{Binding AMNRKRS}" Width="24" />
                    <TextBlock Text="{Binding AMLFDNR}" Width="48"   />
                    <TextBlock Text="{Binding AMPOS}" Width="36" />
                    <ex:TXT72 Text="{Binding AMBEZ,Converter={StaticResource gb2312}}" Width="200" />
                    <TextBlock Text="{Binding Source={Localization:Translate Word=IP地址:}}"/>
                    <ex:TXT72 Text="{Binding AMHERST,Converter={StaticResource gb2312}}" Width="200" />
                </WrapPanel>
                <WrapPanel>
                    <CheckBox Content="{Binding Source={Localization:Translate Word=标准}}" IsChecked="{Binding IsSTD,ElementName=TV}"/>
                    <TextBlock   Text="{Binding Source={Localization:Translate Word=库位:}}"/>
                    <WrapPanel>
                        <ex:TXT72  MaxLength="2" CharacterCasing="Upper"  Text="{Binding AMLO}" Width="30"/>
                        <ex:TXT72  MaxLength="2" CharacterCasing="Upper"  Text="{Binding AMLB}" Width="30"/>
                        <ex:TXT72  MaxLength="8" CharacterCasing="Upper"  Text="{Binding AMLPLATZ}" Width="60"/>
                        <CheckBox  Grid.Column="1" Name="cWH"></CheckBox>
                        <WH:TSWH  KEY="{Binding WH,ElementName=TV}" 
                                  Visibility="{Binding IsChecked,ElementName=cWH,Converter={StaticResource bv}}"/>
                    </WrapPanel>

                    <LS:TSLS02 Grid.Column="1"  
                                 IsEdit="{Binding IsEdit,ElementName=TV}"
                                   KEY="{Binding Path=LIEFNR,ElementName=TV}"
                                  ORDERNUM="{Binding Path=LIEFNR,ElementName=TV}"
                                    />
                    <SD:K8881 Grid.Column="1"  
                                  IsEdit="{Binding IsEdit,ElementName=TV}"
                                   KEY="{Binding Path=AMKST,ElementName=TV}"
                                 ORDERNUM="{Binding Path=AMKST,ElementName=TV}"
                                   Width="Auto" />
                    <SD:K0224 KEY="{Binding AMART,ElementName=TV}"
                          IsEdit="{Binding IsEdit,ElementName=TV}"
                          ORDERNUM="{Binding AMART,ElementName=TV}"
                          />
                    <SD:K0228 KEY="{Binding AMTYP,ElementName=TV}"
                          IsEdit="{Binding IsEdit,ElementName=TV}"
                          ORDERNUM="{Binding AMTYP,ElementName=TV}"
                          />
                    <KS:TSKS03 Grid.Column="1" 
                                  IsEdit="True"
                                   KEY="{Binding Path=AMKST,ElementName=TV}"
                            ORDERNUM="{Binding Path=AMKST,ElementName=TV}"
                                   Width="Auto" />

                </WrapPanel>
            </StackPanel>
        </StackPanel>
        <DataGrid  Grid.Row="1"  Grid.Column="0" 
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   IsReadOnly="True"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"     
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}" 
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible"  
                    >
            <DataGrid.Columns>
                <DataGridTextColumn  Binding="{Binding AMSTDVAR}" Header="{Binding Source={Localization:Translate Word=标准}}" />
                <DataGridTextColumn  Binding="{Binding AMNRKRS}"  />                
                <DataGridTextColumn Binding="{Binding Path=AMLFDNR}" Header="{Binding Source={Localization:Translate Word=设备}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding AMPOS}" Width="Auto"/>
                <DataGridTextColumn  Binding="{Binding AMBEZ,Converter={StaticResource gb2312}}" Header="{Binding Source={Localization:Translate Word=说明}}" Width="Auto"/>
                <DataGridTextColumn Binding="{Binding Path=AMHERST}" Header="{Binding Source={Localization:Translate Word=制造商}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMTYP,Converter={StaticResource sd},ConverterParameter=0228}" Header="{Binding Source={Localization:Translate Word=型号}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMART,Converter={StaticResource sd},ConverterParameter=0224}" Header="{Binding Source={Localization:Translate Word=类型}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMKSTKRS}"  Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMLO}" Header="{Binding Source={Localization:Translate Word=LO}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMLB}" Header="{Binding Source={Localization:Translate Word=LB}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMLPLATZ}" Header="{Binding Source={Localization:Translate Word=LP}}" Width="Auto"  />
            </DataGrid.Columns>
        </DataGrid  >
        <TabControl Grid.Row="1"  Grid.Column="1">
            <TabItem Header="{Binding Source={Localization:Translate Word=参数}}">
                <AME:TAMEZL   Grid.Row="1"  Name="cAM06"
                          EXAUF="{Binding KEY,ElementName=cAM05}" />
            </TabItem>
            <TabItem Header="{Binding Source={Localization:Translate Word=模块}}">
                <AMD:TAMMODUL  Grid.Row="0"     Name="cAM05"
                          EXAUF="{Binding KEY,ElementName=TV}"/>
            </TabItem> 
        </TabControl> 
        <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <AE:TMEKOPF Grid.Column="0" Grid.ColumnSpan="2"
                        Name="cAE"
                        EXAUF="{Binding KEY,ElementName=TV}" />
        </Grid>
        <Expander Grid.Row="3" Grid.Column="0">
            <Expander.Header>
                <WrapPanel>
                    <TextBlock Text="{Binding Source={Localization:Translate Word=运行监控}}" >
                    </TextBlock>
                </WrapPanel>
            </Expander.Header>
            <ListBox    ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}"  
                                ScrollViewer.CanContentScroll="True">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel  MaxWidth="800"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="100">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Row="0" Text="{Binding Path=AMBDEMA}"/>
                            <me:TMON Grid.Row="1"/>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <!--Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="1*"/>
                    </Grid.RowDefinitions>
                    <ListView    ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}"  FlowDirection="LeftToRight" Width="800"   >
                        <ListView.View>
                            <GridView>
                                <GridViewColumn>
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <me:TMON/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </Grid-->
        </Expander>
    </Grid>
</me:UIAM>
